﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace lcs.Web.user
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtuser_name.Text.Trim().Length==0)
			{
				strErr+="user_name不能为空！\\n";	
			}
			if(this.txtuser_login.Text.Trim().Length==0)
			{
				strErr+="user_login不能为空！\\n";	
			}
			if(this.txtuser_pass.Text.Trim().Length==0)
			{
				strErr+="user_pass不能为空！\\n";	
			}
			if(this.txtuser_mobelPhone.Text.Trim().Length==0)
			{
				strErr+="user_mobelPhone不能为空！\\n";	
			}
			if(this.txtuser_phone.Text.Trim().Length==0)
			{
				strErr+="user_phone不能为空！\\n";	
			}
			if(this.txtuser_fax.Text.Trim().Length==0)
			{
				strErr+="user_fax不能为空！\\n";	
			}
			if(this.txtuser_company.Text.Trim().Length==0)
			{
				strErr+="user_company不能为空！\\n";	
			}
			if(this.txtuser_email.Text.Trim().Length==0)
			{
				strErr+="user_email不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtroles_id.Text))
			{
				strErr+="所属角色格式错误！\\n";	
			}
			if(this.txtremark.Text.Trim().Length==0)
			{
				strErr+="remark不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtsid.Text))
			{
				strErr+="物料员所管仓库格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string user_name=this.txtuser_name.Text;
			string user_login=this.txtuser_login.Text;
			string user_pass=this.txtuser_pass.Text;
			string user_mobelPhone=this.txtuser_mobelPhone.Text;
			string user_phone=this.txtuser_phone.Text;
			string user_fax=this.txtuser_fax.Text;
			string user_company=this.txtuser_company.Text;
			string user_email=this.txtuser_email.Text;
			int roles_id=int.Parse(this.txtroles_id.Text);
			string remark=this.txtremark.Text;
			int sid=int.Parse(this.txtsid.Text);

			lcs.Model.user model=new lcs.Model.user();
			model.user_name=user_name;
			model.user_login=user_login;
			model.user_pass=user_pass;
			model.user_mobelPhone=user_mobelPhone;
			model.user_phone=user_phone;
			model.user_fax=user_fax;
			model.user_company=user_company;
			model.user_email=user_email;
			model.roles_id=roles_id;
			model.remark=remark;
			model.sid=sid;

			lcs.BLL.user bll=new lcs.BLL.user();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","Add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
